<template>
    <Card>
      <p slot="title">
          征信复核
      </p>
      <Row type="flex" justify="center" align="middle">
          <Col span="3"> 复核结果
          </Col>
          <Col span="21">
          <Select v-model="resultOption" @on-change="resultOptionChange" label-in-value style="width:200px;">
              <Option v-for="item in resultOptions" :value="item.value" :key="item.value">{{ item.label }}</Option>
          </Select>
          </Col>
          <!-- <Col span="6">
              资金来源
          </Col>
          <Col span="6">
              {{fundName}}
          </Col> -->
      </Row>
      <br>
      <Collapse value="1" v-if="resultOption == 'OK'">
          <Panel name="1">
              复核结果
              <p slot="content">
                <Form label-position="top">
                    <FormItem label="审批确认" class="labelWeightBold">
                        <CheckboxGroup v-model="processOpinions">
                            <Checkbox :label="child.opinionTypeCode" v-for="child in opinionTypes3" :key="child.id">
                                <span>{{child.opinionTypeName}}</span>
                            </Checkbox>
                        </CheckboxGroup>
                    </FormItem>
                    <FormItem label="征信意见" class="labelWeightBold">
                        <Input v-model="checkOpinionContent" type="textarea" :autosize="{minRows: 5,maxRows: 5}" placeholder="请输入内容"></Input>
                    </FormItem>
                    <FormItem label="违例代码" class="labelWeightBold">
                      <Row>
                        <Col span="12">
                        <Select v-model="violationOne" style="width:300px" @on-change="violationOneOptionChange" label-in-value>
                            <Option v-for="item in violationOptions" :value="item.opinionTypeCode" :key="item.id">{{ item.opinionTypeName }}</Option>
                        </Select>
                        </Col>
                        <Col span="12">
                        <Select v-model="violationTwo" style="width:300px" label-in-value>
                            <Option v-for="item in violationTwoOptions" :value="item.opinionTypeCode" :key="item.id">{{ item.opinionTypeName }}</Option>
                        </Select>
                        </Col>
                      </Row>
                    </FormItem>
                    <FormItem label="违例意见" class="labelWeightBold">
                        <Input v-model="violationOptionContent" type="textarea" :autosize="{minRows: 5,maxRows: 5}" placeholder="请输入内容"></Input>
                    </FormItem>
                </Form>
              </p>
          </Panel>
      </Collapse>
      <Collapse value="1" v-if="resultOption == 'RETURN'">
          <Panel name="1">
              复核结果
              <p slot="content">
                <Form label-position="top">
                  <FormItem label="退回原因" class="labelWeightBold">
                    <Input v-model="returnReason" type="textarea" :autosize="{minRows: 5,maxRows: 5}" placeholder="请输入内容"></Input>
                  </FormItem>
                </Form>
              </p>
          </Panel>
      </Collapse>
      <Collapse value="1" v-if="resultOption == 'RETURN_APP'">
          <Panel name="1">
              复核结果
              <p slot="content">
                <Form label-position="top">
                    <FormItem label="退回原因大类" class="labelWeightBold">
                        <CheckboxGroup v-model="returnAppOpinionCheckeds">
                            <Checkbox :label="child.opinionTypeCode" v-for="child in returnAppOpinions" :key="child.id">
                                <span>{{child.opinionTypeName}}</span>
                            </Checkbox>
                        </CheckboxGroup>
                    </FormItem>
                    <FormItem label="退补件意见" class="labelWeightBold">
                        <Input v-model="returnAppOpinionContent" type="textarea" :autosize="{minRows: 5,maxRows: 5}" placeholder="请输入内容"></Input>
                    </FormItem>
                </Form>
              </p>
          </Panel>
      </Collapse>
      <Collapse value="1" v-if="resultOption == 'REFUSE'">
          <Panel name="1">
              复核结果
              <p slot="content">
                <Form label-position="top">
                  <FormItem label="拒绝代码" class="labelWeightBold">
                    <div>
                      <Button type="info" size="small" @click="openOpinionsModal">选择拒绝意见</Button>
                    </div>
                    <Tag color="primary" v-for="item in choosedOpinionTypesLv3" :key="item.id" :name="item.opinionTypeCode">{{ item.opinionTypeName }}</Tag>
                  </FormItem>
                  <FormItem label="拒绝意见" class="labelWeightBold">
                      <Input v-model="refuseOpinionContent" type="textarea" :autosize="{minRows: 5,maxRows: 5}" placeholder="请输入内容"></Input>
                  </FormItem>
                </Form>
              </p>
          </Panel>
      </Collapse>
        <br>
        <div style="text-align:center">
            <Button type="primary" @click="saveOpinionBt" :disabled="taskParams.type!=1" >保存</Button>
            <Button type="primary" @click="complateOpinionBt" :disabled="taskParams.type!=1" >提交</Button>
        </div>
        <br>
        <Collapse value="1" v-if="approvalLogs && approvalLogs.length > 0">
            <Panel name="1">
                审批流程
                <p slot="content">
                  <Timeline>
                      <TimelineItem v-for="(item,index) in approvalLogs" :key="item.node_name+'_'+index">
                          <p class="common-title">{{item.updatedDate}}</p>
                          <p class="common-title">{{item.nodeName}}</p>
                          <p class="common-content" v-if="item.caseResult=='OK'">复核结果：通过</p>
                          <p class="common-content" v-if="item.caseResult=='REFUSE'">复核结果：拒绝</p>
                          <p class="common-content" v-if="item.caseResult=='RETURN'">复核结果：退回</p>
                          <p class="common-content" v-if="item.caseResult=='RETURN_APP'">复核结果：退回前端</p>
                          <p class="common-content">类型名称：{{item.opinionTypeName}}</p>
                          <p class="common-content" v-if="item.opinionClass==3">复核意见：{{item.opinion}}</p>
                          <p class="common-content" v-if="item.opinionClass==1">违例意见：{{item.opinion}}</p>
                          <p class="common-content" v-if="item.opinionClass==0">拒绝意见：{{item.opinion}}</p>
                          <p class="common-content" v-if="item.opinionClass==4">退回APP意见：{{item.opinion}}</p>
                          <p class="common-content" v-if="item.opinionClass==5">退回意见：{{item.opinion}}</p>
                          <p class="common-content">处理人员：{{item.updatedBy}}</p>
                      </TimelineItem>
                  </Timeline>
                </p>
            </Panel>
        </Collapse>
        <Modal
            v-model="modal1"
            title="拒绝代码"
            :footer-hide="true"
            width="900">
            <Row>
              <Col>
                <Tag color="primary" v-for="item in choosedOpinionTypesLv3" :key="item.id" :name="item.opinionTypeCode" closable @on-close="closeTag">{{ item.opinionTypeName }}</Tag>
              </Col>
            </Row>
            <br>
            <div class="common-split">
                <Split v-model="split1">
                    <div slot="left" class="common-split-pane">
                      <!-- 左侧一级菜单 -->
                      <CellGroup @on-click="clickCell">
                        <Row v-for="item in checkOpinionTypes" :key="item.opinionTypeCode">
                          <Col>
                            <Badge :count="countOpinionTypesLv1(item.opinionTypeCode)" :offset="[20,-5]">
                              <Cell  :title="item.opinionTypeName" :name="item.opinionTypeCode"  :selected="item.selected"/>
                            </Badge>
                          </Col>
                        </Row>
                      </CellGroup>
                    </div>
                    <div slot="right" class="common-split-pane">
                      <!-- 二级菜单（按照二级菜单个数分行展示） -->
                      <Row v-if="checkTwoOpinionTypes && checkTwoOpinionTypes.length>0" v-for="rowNum in Math.ceil(checkTwoOpinionTypes.length/3)" :key="'rowNum'+rowNum">
                        <Col span="8" v-for="(item,index) in checkTwoOpinionTypes" :key="item.opinionTypeCode" v-if="index<rowNum*3 && index>=(rowNum-1)*3">
                          <Poptip trigger="hover" placement="right" word-wrap style="width:250px;">
                              <Button type="text">{{item.opinionTypeName}}</Button>
                              <div class="api" slot="content">
                                  <!-- 三级菜单 -->
                                  <!-- <Row v-if="item.opinionTypes && item.opinionTypes.length > 0">
                                      <Col v-for="(item3) in item.opinionTypes" :key="item3.opinionTypeCode"><Button type="text">{{item3.opinionTypeName}}</Button></Col>
                                  </Row> -->
                                  <CheckboxGroup v-model="choosedLv3" v-if="item.opinionTypes && item.opinionTypes.length > 0" @on-change="changeOpinionTypeLv3(item.opinionTypes)">
                                      <Checkbox v-for="(item3) in item.opinionTypes" :key="item3.opinionTypeCode" :label="item3.opinionTypeCode">
                                          <span>{{item3.opinionTypeName}}</span>
                                      </Checkbox>
                                  </CheckboxGroup>
                              </div>
                          </Poptip>
                        </Col>
                      </Row>
                    </div>
                </Split>
            </div>
        </Modal>
    </Card>
</template>

<script>
export default {
  name: 'loan-checking-form',
  data () {
    return {
      modal1: false,
      split1: 0.2,
      loanId: '17050617222455105',
      fundName: null,
      resultOption: null,
      resultOptions: [
        {
          label: '通过',
          value: 'OK'
        },
        {
          label: '退回',
          value: 'RETURN'
        },
        {
          label: '退回到前端',
          value: 'RETURN_APP'
        },
        {
          label: '拒绝',
          value: 'REFUSE'
        }
      ],
      loanApplyCase: {

      },
      approvalLogs: [],
      // 审批确认
      opinionTypes3: [
      ],
      processOpinions: [],
      thisCourse: null,
      checkOpinionContent: null,
      violationOne: null,
      violationTwo: null,
      violationOptions: [],
      violationTwoOptions: [],
      violationOptionContent: null,
      returnReason: null, // 退回原因
      // 退回原因大类
      returnAppOpinions: [],
      returnAppOpinionCheckeds: [],
      returnAppOpinionContent: null,
      // 拒绝
      checkOpinionTypes: [],
      checkOpinionTypeCheckeds: [],
      checkTwoOpinionTypes: [],
      checkTwoOpinionTypeCheckeds: [],
      checkThreeOpinionTypes: [],
      checkThreeOpinionTypeCheckeds: [],
      refuseOpinionContent: null, // 拒绝意见
      choosedLv3: [], // 选中的三级菜单选项
      lastChoosedLv3: [], // 最近一次选中的三级菜单选项
      choosedOpinionTypesLv3: [] // 选中的三级菜单对象
    }
  },
  methods: {
    // 保存
    saveOpinionBt () {
      if (!this.resultOption) {
        this.$Message.warning('请选择审批结果')
        return
      }
      // 获取审批结果
      var params = this.setParams()
      this.$ajax.post(this.$appContext.marvels_core_approve + 'approve/checking/service/addchecking', params).then(re => {
        if (re.data.code === 'success') {
          this.$Message.success({ title: '提示', content: re.data.data.loanId + '保存成功!', onOk () { } })
          // vm.query_status_num();
        } else {
          this.$Message.error({ title: '提示', content: re.data.data, onOk () { } })
        }
      }).catch(er => {
      })
    },
    // 封装审批结果
    setParams () {
      var params = {}
      params.loanId = this.loanId
      params.processResult = this.resultOption
      // 审批确认
      var processOpinions = []
      if (this.processOpinions.length !== 0) {
        for (let i = 0; i < this.processOpinions.length; i++) {
          processOpinions.push({ opinionTypeCode: this.processOpinions[i] })
        }
      }
      params.processOpinions = processOpinions
      // 违例代码
      params.violationOpinion = this.violationTwo
      // 违例意见
      params.violationOptionContent = this.violationOptionContent
      // 退回原因大类
      var returnAppOpinions = []
      if (this.returnAppOpinionCheckeds.length !== 0) {
        for (let i = 0; i < this.returnAppOpinionCheckeds.length; i++) {
          returnAppOpinions.push({ opinionTypeCode: this.returnAppOpinionCheckeds[i] })
        }
      }
      params.returnAppOpinions = returnAppOpinions
      params.returnAppOpinionContent = this.returnAppOpinionContent
      // 拒绝代码
      var refuseOpinionTypes = []
      for (let i = 0; i < this.choosedOpinionTypesLv3.length; i++) {
        refuseOpinionTypes.push({ opinionTypeCode: this.choosedOpinionTypesLv3[i].opinionTypeCode })
      }
      params.checkOpinionTypes = refuseOpinionTypes
      if (params.processResult === 'OK') {
        // 征信意见
        params.checkOpinionContent = this.checkOpinionContent
      } else if (params.processResult === 'REFUSE') {
        // 拒绝意见
        params.checkOpinionContent = this.refuseOpinionContent
      } else if (params.processResult === 'RETURN') {
        // 退回原因
        params.checkOpinionContent = this.returnReason
      }
      return params
    },
    handleSubmit (params) {
      var config = {
        title: '提示',
        content: '是否确认提交?',
        onOk: () => {
          this.doSubmit(params)
        }
      }
      this.$Modal.confirm(config)
    },
    // 提交
    complateOpinionBt () {
      if (!this.resultOption) {
        this.$Message.warning('请选择审批结果')
        return
      }
      // 获取审批结果
      var params = this.setParams()
      var validate = this.validSubmitData(params)
      if (validate) {
        this.handleSubmit(params)
      }
    },
    doSubmit (params) {
      this.$ajax.post(this.$appContext.marvels_core_approve + 'approve/checking/service/complateChecking', params).then(re => {
        if (re.data.code === 'success') {
          this.$Message.success({ title: '提示', content: re.data.data.loanId + '提交复核成功!', onOk () { } })
          this.$router.back()
        // vm.query_status_num();
        } else {
          this.$Message.error({ title: '提示', content: re.data.data.loanId + '提交复核失败', onOk () { } })
        }
      }).catch(er => {
      })
    },
    // 校验提交数据
    validSubmitData (params) {
      var flag = true
      if (params.processResult === 'OK') {
        if (!params.processOpinions || params.processOpinions.length < 1) {
          this.$Message.warning('审批确认选项不能为空')
          flag = false
        }
      } else if (params.processResult === 'RETURN') {
        if (!params.checkOpinionContent || params.checkOpinionContent == null || params.checkOpinionContent === '') {
          this.$Message.warning('退回原因不能为空')
          flag = false
        }
      } else if (params.processResult === 'RETURN_APP') {
        if (!params.returnAppOpinions || params.returnAppOpinions.length < 1) {
          this.$Message.warning('退回原因选项不能为空')
          flag = false
        }
      } else if (params.processResult === 'REFUSE') {
        if (!params.checkOpinionTypes || params.checkOpinionTypes.length < 1) {
          this.$Message.warning('拒绝意见选项不能为空')
          flag = false
        }
      }
      return flag
    },
    // 拒绝one
    checkOneOptionChange (opinion) {
      this.checkTwoOpinionTypes = []
      this.checkOpinionTypes.forEach(item => {
        var itemCode = item.opinionTypeCode
        var oneItem = item.opinionTypes
        opinion.forEach(item2 => {
          if (itemCode === item2) {
            this.checkTwoOpinionTypes = this.checkTwoOpinionTypes.concat(oneItem)
          }
        })
      })
    },
    // 拒绝two
    checkTwoOptionChange (opinion) {
      this.checkThreeOpinionTypes = []
      this.checkTwoOpinionTypes.forEach(item => {
        var itemCode = item.opinionTypeCode
        var oneItem = item.opinionTypes
        opinion.forEach(item2 => {
          if (itemCode === item2) {
            this.checkThreeOpinionTypes = this.checkThreeOpinionTypes.concat(oneItem)
          }
        })
      })
    },
    // OK违例第一select
    violationOneOptionChange (option) {
      var optionKey = option.value
      this.violationTwo = null
      this.violationTwoOptions = []
      this.violationOptions.forEach(item => {
        var otCode = item.opinionTypeCode
        if (optionKey === otCode) {
          var opinionTypes = item.opinionTypes || []
          opinionTypes.forEach(item2 => {
            this.violationTwoOptions.push(item2)
          })
        }
      })
    },
    resultOptionChange (option) {
      // 审批确认
      this.processOpinions = []
      this.checkOpinionContent = null
      // 违例
      this.violationTwo = null
      this.violationOne = null
      this.violationOptionContent = null
      // 退回原因大类
      this.returnAppOpinionContent = null
      this.returnAppOpinionCheckeds = []
      // 拒绝
      this.checkOpinionTypeCheckeds = []
      this.checkTwoOpinionTypeCheckeds = []
      this.checkThreeOpinionTypeCheckeds = []
      this.refuseOpinionContent = null
      this.choosedLv3 = []
      this.lastChoosedLv3 = []
      this.choosedOpinionTypesLv3 = []
    },
    openOpinionsModal () {
      if (this.resultOption === 'REFUSE') {
        this.modal1 = true
      } else {
        this.modal1 = false
      }
    },
    // 加载审批结果
    loadFormData (data) { // 0 拒绝  1违例  2复核意见 3审批确认   4退回app  5退回上个流程
      var vm = this
      if (data && data.length > 0) {
        var opinion = data[0]
        vm.resultOption = opinion.caseResult
        if (opinion.caseResult === 'OK') { // 通过
          data.forEach(item => {
            if (item.opinionClass === 3) { // 渲染审批确认checkbox
              vm.checkOpinionContent = item.opinion
              vm.processOpinions.push(item.opinionTypeCode)
            } else if (item.opinionClass === 1) { // 渲染违例代码
              vm.violationOptionContent = item.opinion
              for (let i = 0; i < vm.violationOptions.length; i++) { // 一级违例代码列表
                let violationOptionsLv2 = vm.violationOptions[i].opinionTypes
                for (let j = 0; j < violationOptionsLv2.length; j++) { // 二级违例代码列表
                  if (item.opinionTypeCode === violationOptionsLv2[j].opinionTypeCode) {
                    vm.violationOne = violationOptionsLv2[j].opinionSupCode
                    vm.violationTwoOptions = violationOptionsLv2
                    vm.violationTwo = item.opinionTypeCode
                    return
                  }
                }
              }
            }
          })
        } else if (opinion.caseResult === 'RETURN') {
          vm.returnReason = opinion.opinion
        } else if (opinion.caseResult === 'RETURN_APP') { // 退回到前端
          vm.returnAppOpinionContent = opinion.opinion
          data.forEach(item => {
            vm.returnAppOpinionCheckeds.push(item.opinionTypeCode)
          })
        } else if (opinion.caseResult === 'REFUSE') { // 拒绝
          vm.refuseOpinionContent = opinion.opinion
          let ary = [] // 选中的三级菜单
          data.forEach(item => {
            ary.push(item.opinionTypeCode)
          })
          vm.loadModalData(ary)
        }
      }
    },
    initChecking () {
      var vm = this
      var params = {}
      params.loanId = this.loanId
      this.$ajax.post(this.$appContext.marvels_core_approve + 'approve/checking/service/qchecking', params).then(re => {
        if (re.data.code === 'success') {
          // 当前单据类型：是线上还是线下
          var patternCode = re.data.data.loanApplyCase.patternCode
          this.opinionTypes3 = []
          var datas = re.data.data.opinionTypes[3] || []
          datas.forEach(item => {
            this.opinionTypes3.push(item)
          })
          this.violationOptions = []
          var violationDatas = re.data.data.opinionTypes[1] || []
          violationDatas.forEach(item => {
            if (item.patternCode === patternCode) {
              this.violationOptions.push(item)
            }
          })
          // 退回前端
          this.returnAppOpinions = []
          var returnOpinionDatas = re.data.data.opinionTypes[4] || []
          returnOpinionDatas.forEach(item => {
            this.returnAppOpinions.push(item)
          })
          vm.initApprovalLogDatas(re.data.data.logs)
          // 拒绝
          vm.checkOpinionTypes = []
          // vm.initRefuseOpinionList(re.data.data.opinionTypes[0])
          var checkOpinionDatas = re.data.data.opinionTypes[0] || []
          // 获取当前单据类型的拒绝列表
          checkOpinionDatas.forEach(item => {
            if (item.patternCode === patternCode) {
              vm.checkOpinionTypes.push(item)
            }
          })
          vm.initRefuseOpinionTree()
          vm.loadFormData(re.data.data.opinions)
        } else {
          this.$Message.error(re.data.message)
        }
      }).catch(er => {
      })
    },
    initApprovalLogDatas (list) {
      // approvalLogDatas
      var vm = this
      list.forEach(item => {
        item.updatedDate = this.$util.formatTime(new Date(item.updatedDate))
        for (let i = 0; i < vm.resultOptions.length; i++) {
          if (vm.resultOptions[i].value === item.caseResult) {
            item.caseResultName = vm.resultOptions[i].label
          }
        }
        this.approvalLogs.push(item)
      })
    },
    // 初始化拒绝意见列表, 组装成树形结构
    initRefuseOpinionList (data) {
      var refuseOpinionTree = []
      if (data && data.length > 0) {
        for (let i = 0; i < data.length; i++) {
          if (data[i].opinionLevel === 1) {
            let rootNode = data[i]
            rootNode.children = this.parseData(rootNode, data)
            refuseOpinionTree.push(rootNode)
          }
        }
      }
    },
    // 递归组装树结构数据
    parseData (parentNode, list) {
      let children = []
      if (list && list.length > 0) {
        for (let i = 0; i < list.length; i++) {
          if (parentNode.nodeCode === list[i].opinionSupCode) {
            children.push(list[i])
          }
        }
        if (children && children.length > 0) {
          for (let i = 0; i < children.length; i++) {
            children[i].children = this.parseData(children[i], list)
          }
        }
      }
      return children
    },
    // 初始化三层级联拒绝意见树，三级菜单保存一级菜单路径
    initRefuseOpinionTree () {
      var vm = this
      // 一级菜单
      this.checkOpinionTypes.forEach(item => {
        // 二级菜单
        item.opinionTypes.forEach(item2 => {
          // vm.checkTwoOpinionTypes.push(item2)
          // 三级菜单
          item2.opinionTypes.forEach(item3 => {
            vm.$set(item3, 'rootNode', item.opinionTypeCode)
            vm.checkThreeOpinionTypes.push(item3)
          })
        })
      })
    },
    // 一级菜单单击事件
    clickCell (name) {
      var vm = this
      this.checkOpinionTypes.forEach(item => {
        if (item.opinionTypeCode === name) {
          vm.$set(item, 'selected', true)
          vm.checkTwoOpinionTypes = item.opinionTypes
        } else {
          vm.$set(item, 'selected', false)
        }
      })
    },
    /**
     * 三级菜单选中事件
     * 入参ary：当前变更的三级菜单对象数据
     */
    changeOpinionTypeLv3 (ary) {
      var vm = this
      let lastLength = this.lastChoosedLv3.length // 上一次选择的三级菜单个数
      let length = this.choosedLv3.length // 本次选择的三级菜单个数
      let changeType = 'add' // checkbox的change事件：add=选中，del=取消
      let changedopinionTypeCode = null // 变更的三级菜单code
      if (lastLength > length) {
        changeType = 'del'
      }
      if (changeType === 'add') {
        changedopinionTypeCode = this.getChangedOpinionTypeLv3(this.choosedLv3, this.lastChoosedLv3)
      } else if (changeType === 'del') {
        changedopinionTypeCode = this.getChangedOpinionTypeLv3(this.lastChoosedLv3, this.choosedLv3)
      }
      ary.forEach(item => {
        if (item.opinionTypeCode === changedopinionTypeCode) {
          vm.updateChoosedOpinionTypesLv3(item, changeType)
        }
      })
      // 将本次的三级菜单对象复制给上次的三级菜单对象
      this.lastChoosedLv3 = this.$util.cloneObject(this.choosedLv3)
    },
    // 比较两个数组，返回多出的元素
    getChangedOpinionTypeLv3 (ary1, ary2) {
      for (let i = 0; i < ary1.length; i++) {
        var existFlag = false
        for (let j = 0; j < ary2.length; j++) {
          if (ary1[i] === ary2[j]) {
            existFlag = true
          }
        }
        if (!existFlag) {
          return ary1[i]
        }
      }
    },
    // 更新选中的三级菜单对象数组
    updateChoosedOpinionTypesLv3 (item, type) {
      if (type === 'add') {
        this.choosedOpinionTypesLv3.push(item)
      } else if (type === 'del') {
        var index = null
        for (let i = 0; i < this.choosedOpinionTypesLv3.length; i++) {
          if (this.choosedOpinionTypesLv3[i].opinionTypeCode === item.opinionTypeCode) {
            index = i
          }
        }
        if (index >= 0) {
          this.choosedOpinionTypesLv3.splice(index, 1)
        }
      }
    },
    // 关闭选中的三级菜单标签
    closeTag (event, name) {
      var indexAry = []
      var index = null
      for (let i = 0; i < this.choosedOpinionTypesLv3.length; i++) {
        if (this.choosedOpinionTypesLv3[i].opinionTypeCode === name) {
          indexAry.push(i)
        }
      }
      // 删除三级菜单标签对应的选中的三级菜单对象数组元素
      if (indexAry.length > 0) {
        for (let i = 0; i < indexAry.length; i++) {
          this.choosedOpinionTypesLv3.splice(indexAry[i], 1)
        }
      }
      for (let i = 0; i < this.choosedLv3.length; i++) {
        if (this.choosedLv3[i] === name) {
          index = i
        }
      }
      // 删除三级菜单标签对应的选中的三级菜单
      if (index >= 0) {
        this.choosedLv3.splice(index, 1)
        this.lastChoosedLv3 = this.$util.cloneObject(this.choosedLv3)
      }
    },
    // 计算每个一级菜单下选中的三级菜单个数
    countOpinionTypesLv1 (OpinionTypeCodeLv1) {
      let count = 0
      for (let i = 0; i < this.choosedOpinionTypesLv3.length; i++) {
        if (this.choosedOpinionTypesLv3[i].rootNode === OpinionTypeCodeLv1) {
          count++
        }
      }
      return count
    },
    /**
      渲染菜单数据
      入参data(Array)：选中的三级菜单code
     */
    loadModalData (data) {
      if (data && data.length > 0) {
        this.choosedLv3 = this.$util.cloneObject(data)
        this.lastChoosedLv3 = this.$util.cloneObject(this.choosedLv3)
        for (let j = 0; j < data.length; j++) {
          for (let i = 0; i < this.checkThreeOpinionTypes.length; i++) {
            if (data[j] === this.checkThreeOpinionTypes[i].opinionTypeCode) {
              this.choosedOpinionTypesLv3.push(this.checkThreeOpinionTypes[i])
            }
          }
        }
      }
    }
  },
  computed: {

  },
  mounted () {

  },
  created () {
    this.$ajax = this.$util.ajax()
  },
  watch: {
    // 点击tab页签，加载数据，只加载一次
    'taskParams.approvalResult' (v) {
      if (v) {
        this.loanId = this.taskParams.curLoanId
        this.initChecking()
      }
    }
  },

  props: {
    taskParams: Object
  }
}
</script>
<style>
.checkCard Row {
  border-bottom: 1px;
  margin: 0px 0px 5px 0px;
}
.f14 input {
  cursor: pointer;
}

.labelWeightBold{
  font-weight: bold;
}
.common-split{
  height:500px;
  border: 1px solid #dcdee2;
}
.common-split-pane{
    padding: 10px;
}
.left-pane{
  overflow-y: auto;
}
</style>
